/*
@author Tobias Drey,Ingmar Flaig
*/
#include "Parser.h"


Parser::Parser(void)
{
}


Parser::~Parser(void)
{
}

	/**

  Read line from a CSV file

  @param[in] fp file pointer to open file
  @param[in] vls reference to vector of strings to hold next line

  */
void Parser::readCSV( FILE *fp, std::vector<std::string>& vls )
{
    vls.clear();
    if( ! fp )
        return;
    char buf[10000];
    if( ! fgets( buf,999,fp) )
        return;
    std::string s = buf;
    int p,q;
    q = -1;
    // loop over columns
    while( 1 ) {
        p = q;
        q = s.find_first_of(",\n",p+1);
        if( q == -1 ) 
                break;
        vls.push_back( s.substr(p+1,q-p-1) );
    }
}
